package com.usian.controller;

import com.usian.car.CarAndUsed;
import com.usian.car.Used;
import com.usian.entity.Result;
import com.usian.entity.ResultCodeEnum;
import com.usian.service.CarLogService;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:张永杰
 * @ClassName: CarAndLogController
 * @Date: 2024/12/11
 * @Description:
 */
@RestController
@RequestMapping("/carlog")
public class CarAndLogController {
    @Autowired
    private CarLogService carLogService;

    /**
     * 查询所有用户记录
     * @param deptId
     * @param post
     * @return
     */
    @PostMapping("findAllCarlog")
    public Result<List<CarAndUsed>> findAllCarlog(@RequestParam(value = "deptId",required = false) Integer deptId, @RequestParam(value = "post",required = false)String post){
        List<CarAndUsed>list = carLogService.findAllCarlog(deptId,post);
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }

    /**
     * 添加记录
     * @param used
     * @return
     */
    @PostMapping("addCarlog")
    public Result addCarlog(@RequestBody Used used){
       return carLogService.addCarlog(used);
    }
}
